//
//  HouseTypeCell.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/4/21.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//  楼盘房型 中的cell

#import "HouseTypeCell.h"
#import "HouseTypeCellModel.h"
#import "UIImageView+WebCache.h"
#import "API.h"

@interface HouseTypeCell()

//房屋 图片
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
//房屋类型 ＋ 几间卧室
@property (weak, nonatomic) IBOutlet UILabel *HouseType;
//房屋面积
@property (weak, nonatomic) IBOutlet UILabel *HouseArea;
//卧室数量
@property (weak, nonatomic) IBOutlet UILabel *WoShiNum;
//卫浴数量
@property (weak, nonatomic) IBOutlet UILabel *WeiYuNum;
//车库数量
@property (weak, nonatomic) IBOutlet UILabel *CheKuNum;
//现房
@property (weak, nonatomic) IBOutlet UILabel *HouseTag;

@property (weak, nonatomic) IBOutlet UILabel *houseImage;
@property (weak, nonatomic) IBOutlet UIView *bottomView;

 //期房，现房，样板房的图片
@property (weak, nonatomic) IBOutlet UIImageView *houseTypeImg1;
//有无房型图的图片
@property (weak, nonatomic) IBOutlet UIImageView *houseTypeImg2;
@property (weak, nonatomic) IBOutlet UIImageView *houseTypeImg3;


@end
@implementation HouseTypeCell

+(instancetype)cellWithcollectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
    static NSString *ID = @"houseTypeCell";
//    NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
//    [NSIndexPath ind]
    HouseTypeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    if (cell == nil)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"HouseTypeCell" owner:nil options:nil]lastObject];
        
        //testjfjdj
        
    }
    return cell;
}

-(void)setModel:(HouseTypeCellModel *)model
{
    _model = model;
    
    
    self.HouseType.text = [NSString stringWithFormat:@"%@:%@间卧室%@间浴室",model.typeName,model.bedRoom,model.bathRoom];
    self.HouseArea.text = [NSString stringWithFormat:@"房屋面积:%zd㎡",[model.areaMi integerValue]];
    self.WoShiNum.text = [NSString stringWithFormat:@"%@间",model.bedRoom];
    self.WeiYuNum.text = [NSString stringWithFormat:@"%@间",model.bathRoom];
    self.CheKuNum.text = [NSString stringWithFormat:@"%@间",model.garage];
    //有房型图
    self.houseImage.text = model.houseTypePicName;
    if ([model.houseTypePicName isEqual:@"有房型图"])
    {
         [self.houseTypeImg2 setImage:[UIImage  imageNamed:@"fangxing_icon_b"]];
    }else
    {
        [self.houseTypeImg2 setImage:[UIImage  imageNamed:@"fangxing_icon_a"]];
    }
    //现房
    self.HouseTag.text = model.houseTypeName;
    
    
    
    if ([model.houseTypeName isEqual:@"现房"])
    {
        self.HouseTag.textColor = [UIColor colorWithRed:225/255.0 green:39/255.0 blue:39/255.0 alpha:1];
        [self.houseTypeImg1 setImage:[UIImage  imageNamed:@"xianfang_icon"]];
        [self.houseTypeImg3 setImage:[UIImage  imageNamed:@"xianfang_a_icon"]];
    }
    else if ([model.houseTypeName isEqual:@"期房"])
    {
        self.HouseTag.textColor = [UIColor colorWithRed:227/255.0 green:64/255.0 blue:39/255.0 alpha:1];
        [self.houseTypeImg1 setImage:[UIImage  imageNamed:@"qifang_icon"]];
        [self.houseTypeImg3 setImage:[UIImage  imageNamed:@"qifang_a_icon"]];
    }
    else
    {
        self.HouseTag.textColor = [UIColor colorWithRed:113/255.0 green:154/255.0 blue:39/255.0 alpha:1];
        [self.houseTypeImg1 setImage:[UIImage  imageNamed:@"yangbanfang_icon"]];
        [self.houseTypeImg3 setImage:[UIImage  imageNamed:@"yangbanfang_a_icon"]];
    }
    NSString *strUrl = [API imgUrlMake:model.thumb];
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:strUrl] placeholderImage:nil];
    
    
}
+(CGSize)getSizeWithCollection:(UICollectionView *)conllection{
    
    static HouseTypeCell *cell = nil;
    
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
      
//        NSInteger row = 1;
//        NSInteger section = 1;
//        NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:section];
//        cell = [HouseTypeCell cellWithcollectionView:conllection cellForItemAtIndexPath:index];
//    });
        cell = [[[NSBundle mainBundle]loadNibNamed:@"HouseTypeCell" owner:nil options:nil]lastObject];;
         });
    return [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];

}



@end
